<?php

namespace App\Http\Requests\App;

use App\Http\Requests\ApiRequest;
use App\Services\Locale\Language;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

/**
 * @property string|null store_id
 * @property string name
 * @property string address
 * @property string phone
 */
class StorePatchInfoRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $data = [
            'store_id'=> 'nullable|int|min:1',
            'name'    => ['required', 'string', 'max:'.self::MAX_STRING],
            'address' => 'required|string|max:'.self::MAX_STRING,
            'phone'   => ['required', 'string', 'max:'.self::MAX_STRING],
        ];

//        if (app()->getLocale() === Language::ZH_CN) {
//            $data['phone'] = ['required', 'regex:/^1[34578][0-9]{9}$|^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/'];
//        } else {
//            $data['phone'] = ['required', 'string'];
//        }

        return $data;
    }

    /**
     * @return array
     */
//    public function messages()
//    {
//        return [
//            'store_id.*' => '店铺编号必须是数值',
//            'name.*'     => '店铺名称必填',
//            'address.*'  => '店铺地址必填',
//            'phone.*'    => '店铺电话必须是合法手机号或座机',
//        ];
//    }
}
